package ph.gov.marikina.mcsmtms.tests;


import java.util.Date;

import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import ph.gov.marikina.mcsmtms.constants.GlobalConstants.Direction;
import ph.gov.marikina.mcsmtms.constants.GlobalConstants.ReportSource;
import ph.gov.marikina.mcsmtms.constants.GlobalConstants.Roads;
import ph.gov.marikina.mcsmtms.constants.GlobalConstants.SituationTypes;
import ph.gov.marikina.mcsmtms.constants.GlobalConstants.TrafficConditionTypes;
import ph.gov.marikina.mcsmtms.dao.SituationReportDAO;
import ph.gov.marikina.mcsmtms.domain.SituationReport;
import ph.gov.marikina.mcsmtms.domain.SituationSegment;

// TODO: Auto-generated Javadoc
/**
 * The Class MainTest.
 */
public class DAOTest {

	/** The log. */
	Logger log = Logger.getLogger(DAOTest.class);

	/** The context. */
	private static ApplicationContext springContext = new ClassPathXmlApplicationContext(
			"spring/test-spring-config.xml");
	
	/** The application context. */
//	private static ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
//			"applicationContext.xml");

	/**
	 * The main method.
	 * 
	 * @param args
	 *            the arguments
	 */
	public static void main(String[] args) {
		// testInsertUserDAO();
		// testFindByUserID();
		// testFindAllUser();
		// testFilterByRoadID();
		// testFilterBySituationType();
		// testFilterByReportSource();
		// testFilterByTrafficCondition();
		// testLookUpDAO();
		// testSituationReportDAO();
		// testInsertIntoSituationReport();
		// testInsertIntoOzekiSmsOut();
		// testUpdateUser();
		// testRegisterUser();
		// testGetAlertUsers();
		// testSendSMS();
		// testRegisterUser();
		// testFilterByDates();
		
		
		testAddSituationReport();
		//addAdressTest();
	}

	private static void testAddSituationReport() {
		//fail("Not yet implemented");
		SituationReportDAO situationReportDAO = (SituationReportDAO) springContext.getBean("situationReportDAO");
		SituationReport situationReport = new SituationReport();
		
		situationReport.setRoad(Roads.BAYAN_BAYANAN.getCode());
		situationReport.setDirection(Direction.A_TO_B.getCode());
		situationReport.setLastUpdateDateTime(new Date());
		situationReport.setReporter(18);
		situationReport.setReportSource(ReportSource.WEB.getCode());
		
		SituationSegment situationSegment = new SituationSegment();
		//situationSegment.setSituationReport(situationReport);
		situationSegment.setSituation(SituationTypes.ACCIDENT.getCode());
		situationSegment.setAccessibleYn(true);
		situationSegment.setTrafficCondition(TrafficConditionTypes.HEAVY.getCode());
		situationSegment.setDescription("Test");
		situationSegment.setStartLat(new Float(0.0));
		situationSegment.setStartLng(new Float(0.0));
		situationSegment.setEndLat(new Float(0.0));
		situationSegment.setEndLng(new Float(0.0));
		
		//List<SituationSegment> situationSegmentList = new ArrayList<SituationSegment>();
		//situationSegmentList.add(situationSegment);
		situationReport.addSituationSegment(situationSegment);
		
		situationReportDAO.addSituationReport(situationReport);
		//Assert
	}
	
	/**
	 * Println.
	 * 
	 * @param msg
	 *            the msg
	 */
	private static void println(String msg) {
		System.out.println(msg);
	}
}